/**
 * Created by yangxianming on 2019-09-03.
 * 用于测试服务器是否启动成功
 */

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

// 扩展 HttpServlet 类
@WebServlet(name = "test1", urlPatterns = {"/test1"}, loadOnStartup = 2)
public class Test1 extends HttpServlet {

    @Override
    public void init(ServletConfig config) throws ServletException {

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        System.out.println("{\"msg\":\"ok\"}");
        out.print("{\"msg\":\"ok\"}");
    }

    public void destroy()
    {
        // 什么也不做
    }

}